package com.xuexiang.xui_lib.component.status;

import ohos.agp.animation.Animator;
import ohos.agp.animation.AnimatorProperty;

public class StateLayoutConfig {
    private static final boolean DEFAULT_ANIM_ENABLED = true;
    /**
     * 页面状态切换是否启用动画
     */
    public boolean animationEnabled;
    /**
     * 进入动画
     */
    public AnimatorProperty inAnimation;
    /**
     * 退出动画
     */
    public AnimatorProperty outAnimation;

    /**
     * 暂无数据
     */
    public int emptyImageRes;
    public String emptyMessageRes;

    /**
     * 出错
     */
    public int errorImageRes;
    public String errorMessageRes;

    /**
     * 断网
     */
    public int offlineImageRes;
    public String offlineMessageRes;

    /**
     * 定位关闭
     */
    public int locationOffImageRes;
    public String locationOffMessageRes;

    /**
     * 重试按钮提示
     */
    public String retryMessageRes;
    /**
     * loading加载提示文字
     */
    public String loadingMessageRes;

    public StateLayoutConfig() {
        animationEnabled = DEFAULT_ANIM_ENABLED;

        inAnimation = createInAnimation();
        outAnimation = createOutAnimation();

        emptyImageRes = com.xuexiang.xui_lib.ResourceTable.Media_stf_ic_empty;
        emptyMessageRes = "暂无数据";

        errorImageRes = com.xuexiang.xui_lib.ResourceTable.Media_stf_ic_error;
        errorMessageRes = "出错了，请稍后重试";

        offlineImageRes = com.xuexiang.xui_lib.ResourceTable.Media_stf_ic_offline;
        offlineMessageRes = "请检查您的网络连接";

        locationOffImageRes = com.xuexiang.xui_lib.ResourceTable.Media_stf_ic_location_off;
        locationOffMessageRes = "请打开定位";

        retryMessageRes = "重试";
        loadingMessageRes = "数据加载中…";
    }

    private AnimatorProperty createOutAnimation() {
        AnimatorProperty animatorProperty = new AnimatorProperty();
        animatorProperty.setDuration(400);
        animatorProperty.alpha(0);
        animatorProperty.alphaFrom(1);
        animatorProperty.moveToX(1000);
        return animatorProperty;
    }

    private AnimatorProperty createInAnimation() {
        AnimatorProperty animatorProperty = new AnimatorProperty();
        animatorProperty.setDuration(400);
        animatorProperty.alpha(1);
        animatorProperty.alphaFrom(0);
        animatorProperty.moveFromX(-200);
        animatorProperty.moveToX(0);
        return animatorProperty;
    }

    public boolean isAnimationEnabled() {
        return animationEnabled;
    }

    public StateLayoutConfig setAnimationEnabled(boolean animationEnabled) {
        this.animationEnabled = animationEnabled;
        return this;
    }

    public Animator getInAnimation() {
        return inAnimation;
    }

    public StateLayoutConfig setInAnimation(AnimatorProperty inAnimation) {
        this.inAnimation = inAnimation;
        return this;
    }

    public Animator getOutAnimation() {
        return outAnimation;
    }

    public StateLayoutConfig setOutAnimation(AnimatorProperty outAnimation) {
        this.outAnimation = outAnimation;
        return this;
    }

    public int getEmptyImageRes() {
        return emptyImageRes;
    }

    public StateLayoutConfig setEmptyImageRes(int emptyImageRes) {
        this.emptyImageRes = emptyImageRes;
        return this;
    }

    public String getEmptyMessageRes() {
        return emptyMessageRes;
    }

    public StateLayoutConfig setEmptyMessageRes(String emptyMessageRes) {
        this.emptyMessageRes = emptyMessageRes;
        return this;
    }

    public int getErrorImageRes() {
        return errorImageRes;
    }

    public StateLayoutConfig setErrorImageRes(int errorImageRes) {
        this.errorImageRes = errorImageRes;
        return this;
    }

    public String getErrorMessageRes() {
        return errorMessageRes;
    }

    public StateLayoutConfig setErrorMessageRes(String errorMessageRes) {
        this.errorMessageRes = errorMessageRes;
        return this;
    }

    public int getOfflineImageRes() {
        return offlineImageRes;
    }

    public StateLayoutConfig setOfflineImageRes(int offlineImageRes) {
        this.offlineImageRes = offlineImageRes;
        return this;
    }

    public String getOfflineMessageRes() {
        return offlineMessageRes;
    }

    public StateLayoutConfig setOfflineMessageRes(String offlineMessageRes) {
        this.offlineMessageRes = offlineMessageRes;
        return this;
    }

    public int getLocationOffImageRes() {
        return locationOffImageRes;
    }

    public StateLayoutConfig setLocationOffImageRes(int locationOffImageRes) {
        this.locationOffImageRes = locationOffImageRes;
        return this;
    }

    public String getLocationOffMessageRes() {
        return locationOffMessageRes;
    }

    public StateLayoutConfig setLocationOffMessageRes(String locationOffMessageRes) {
        this.locationOffMessageRes = locationOffMessageRes;
        return this;
    }

    public String getRetryMessageRes() {
        return retryMessageRes;
    }

    public StateLayoutConfig setRetryMessageRes(String retryMessageRes) {
        this.retryMessageRes = retryMessageRes;
        return this;
    }

    public String getLoadingMessageRes() {
        return loadingMessageRes;
    }

    public StateLayoutConfig setLoadingMessageRes(String loadingMessageRes) {
        this.loadingMessageRes = loadingMessageRes;
        return this;
    }

}
